package com.zy.web.controller.system;

import com.zy.framework.web.base.BaseController;
import com.zy.system.domain.SysDept;
import com.zy.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @program: zhengyang
 * @description: 部门信息
 * @author: Lx
 * @create: 2019-01-08 11:29
 **/
@Controller
@RequestMapping("/system/dept")
public class SysDeptController extends BaseController
{

    private String prefix = "system/dept";

    @Autowired
    private ISysDeptService deptService;

    /**
     * 加载部门列表树
     */
    @GetMapping("/treeData")
    @ResponseBody
    public List<Map<String, Object>> treeData()
    {
        List<Map<String, Object>> tree = deptService.selectDeptTree(new SysDept());
        return tree;
    }
    /**
     * 选择部门树
     */
    @GetMapping("/selectDeptTree/{deptId}")
    public String selectDeptTree(@PathVariable("deptId")Long deptId, ModelMap modelMap)
    {
        modelMap.put("dept",deptService.selectSysDeptById(deptId));
        return prefix + "/tree";
    }
}
